// settings模块 - 存储应用程序设置
const state = {
  language: 'zh-CN', // 默认语言
  theme: 'default',
  showSettings: false,
  tagsView: true,
  fixedHeader: true,
  sidebarLogo: true
}

const mutations = {
  CHANGE_SETTING: (state, { key, value }) => {
    // eslint-disable-next-line no-prototype-builtins
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  },
  SET_LANGUAGE: (state, language) => {
    state.language = language
  }
}

const actions = {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  },
  setLanguage({ commit }, language) {
    commit('SET_LANGUAGE', language)
  }
}

const getters = {
  language: state => state.language,
  theme: state => state.theme
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
